#include "VEnginePCH.h"
#if 0
#include "VUIComCtrl.h"
#include "VUISystem.h"
#include "VUIRoot.h"



UPopupComponent::PopupMaskCtrl::PopupMaskCtrl(UPopupComponent* pOwner)
{
	
	m_Owner = pOwner;
	m_Style = g_USystem->FindControlStyle("default");
}

void UPopupComponent::PopupMaskCtrl::Popup()
{
	VUIRoot *root = g_UIRoot;
	VPoint windowExt = root->GetSize();
	// fit with the desktop
	ResizeControl(VPoint(0,0), windowExt);
	sm_System->PushDialog(this);

	m_Owner->OnPopup();
}

void UPopupComponent::PopupMaskCtrl::ClosePopup()
{
	g_UIRoot->PopDialog(this);	
	m_Owner->OnClosePopup();
}

void UPopupComponent::PopupMaskCtrl::OnMouseDown(const VPoint& point, UINT nRepCnt, UINT uFlags)
{
	ClosePopup();
}




UPopupComponent::UPopupComponent()
{
	m_MaskCtrl = NULL;
	m_PopupCtrl = NULL;
}

UPopupComponent::~UPopupComponent()
{
}

void UPopupComponent::Popup(VUIControl* PopupCtrl)
{
	if (PopupCtrl == NULL)
	{
		return;
	}
	if (m_PopupCtrl)
	{
		ClosePopup();
	}
	
	if (m_MaskCtrl == NULL)
	{
		m_MaskCtrl = new PopupMaskCtrl(this);
	}
	m_PopupCtrl = PopupCtrl;
	m_MaskCtrl->AddChild(PopupCtrl);
	m_MaskCtrl->Popup();
}

void UPopupComponent::ClosePopup()
{
	if (m_MaskCtrl)
	{
		if (m_PopupCtrl)
		{
			m_MaskCtrl->RemoveChild(m_PopupCtrl);
		}
		if (m_PopupCtrl->IsCreated())
		{
			m_PopupCtrl->Destroy();
		}
		m_MaskCtrl->ClosePopup();
		
	}
	m_PopupCtrl = NULL;
}

void UPopupComponent::OnClosePopup()
{
	if (m_MaskCtrl && m_PopupCtrl)
	{
		m_MaskCtrl->RemoveChild(m_PopupCtrl);
	}

	if (m_MaskCtrl)
	{
		delete m_MaskCtrl;
		m_MaskCtrl = NULL;
	}
}

void UPopupComponent::OnPopup()
{

}

#endif 